﻿using System;
using System.Threading;
using System.Threading.Tasks;
using DevExpress.LookAndFeel;
using DevExpress.Skins;

namespace Silent.MDB.Application
{
    static class Program
    {
        [STAThread]
        static void Main()
        {
            SkinManager.EnableFormSkins();
            DevExpress.UserSkins.BonusSkins.Register();
            UserLookAndFeel.Default.SetSkinStyle("DevExpress Style");
            AppDomain.CurrentDomain.UnhandledException += CurrentDomainOnUnhandledException;
            TaskScheduler.UnobservedTaskException += TaskSchedulerOnUnobservedTaskException;
            System.Windows.Forms.Application.ThreadException += ApplicationOnThreadException;
            System.Windows.Forms.Application.EnableVisualStyles();
            System.Windows.Forms.Application.SetCompatibleTextRenderingDefault(false);
            System.Windows.Forms.Application.Run(new MainWindow());
        }

        private static void TaskSchedulerOnUnobservedTaskException(object sender, UnobservedTaskExceptionEventArgs eventArgs)
        {
            Console.WriteLine(eventArgs.Exception);
            eventArgs.SetObserved();
        }

        private static void ApplicationOnThreadException(object sender, ThreadExceptionEventArgs eventArgs)
        {
            Console.WriteLine(eventArgs.Exception);
        }

        private static void CurrentDomainOnUnhandledException(object sender, UnhandledExceptionEventArgs eventArgs)
        {
            Console.WriteLine(eventArgs.ExceptionObject);
        }
    }
}
